<?php
define('IN_WEB', true);
require '../core/core.php';
define('MAGIC_QUOTES_GPC', (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) || @ini_get('magic_quotes_sybase'));
if(!empty($_RQ['i'])) {
	$_SESSION['uniacid'] = intval($_RQ['i']);
}
if(empty($_SESSION['uniacid'])) {
	exit('公众号信息错误');
}
define('IN_SYS',true);
require_once ROOT_D . '/addons/weliam_merchant/core/common/defines.php';
require_once PATH_CORE . 'common/autoload.php';
require ROOT_D.'/api/open_we7/account.php';
require ROOT_D.'/api/open_we7/tplWeb.php';
require ROOT_D.'/api/open_we7/function.php';
$_AR['token'] = token();
Func_loader::core('global');
$_AR['plugin']     = $plugin = !empty($_RQ['p']) ? $_RQ['p'] : 'dashboard';
$_AR['controller'] = $controller = !empty($_RQ['action']) ? $_RQ['action'] : 'dashboard';
$_AR['method']     = $method = !empty($_RQ['do']) ? $_RQ['do'] : 'index';
Func_loader::web('cover');
$_AR['wlsetting'] = Setting::wlsetting_load();
new_method($plugin, $controller, $method);
function new_method($plugin, $controller, $method)
{
    $dir  = ROOT_D . '/addons/' . MODULE_NAME . '/';
    $file = $dir . 'web/controller/' . $plugin . '/' . $controller . '.ctrl.php';
    if (file_exists($file)) {
        require_once $file;
    } else {
        $file = $dir . 'plugin/' . $plugin . '/web/controller/' . $controller . '.ctrl.php';
        if (file_exists($file)) {
            require_once $file;
        } else {
            trigger_error("访问的模块 {$plugin} 不存在.", E_USER_WARNING);
        }
    }
    $class = ucfirst($controller) . '_WeliamController';
    if (class_exists($class, false)) {
        $instance = new $class();
    } else {
        $instance = new $controller();
    }
    if (!method_exists($instance, $method)) {
        trigger_error('控制器 ' . $controller . ' 方法 ' . $method . ' 未找到!');
    }
    $instance->$method();
    exit();
}